//	ID : pallab81
// 	PROG : 10066
// 	LANG : C++
// 	2011-07-27-18.58.14 Wednesday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define fo(i,ed) for(int i = 0 ; i < ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

int n,m;
vector< int > t1,t2;
vector< vector<int> > cando;

inline void read(){
    t1.assign(n+5,0);
    fo(i,n){
        cin>>t1[i];
    }
    t2.assign(m+5,0);
    fo(i,m){
        cin>>t2[i];
    }
}
inline void proc(){
    cando.assign( n+10, vector<int>(m+10,0) );

    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            if( t1[i-1]==t2[j-1] ){
                cando[i][j] = cando[i-1][j-1]+1;
            }
            else{
                cando[i][j] = max(cando[i-1][j],cando[i][j-1]);
            }
        }
    }

}

inline void print(int tower){
    printf("Twin Towers #%d\n",tower);
    printf("Number of Tiles : %d\n",cando[n][m]);
    printf("\n");
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("in.txt","rt",stdin);
    #endif
    int i=1;
    while(cin>>n>>m){
        if( n==0 && m==0 )break;
        read();
        proc();
        print(i);
        ++i;
    }

return 0;
}


